/*
 * @FilePath: index.js
 * @Author: 杜芬
 * @Date: 2021-11-25 16:45:48
 * @LastEditors: Please set LastEditors
 * @LastEditTime: 2025-04-26 16:40:00
 * Copyright: 2023 xxxTech CO.,LTD. All Rights Reserved.
 * @Descripttion: 页面
 */
/*
 * @FilePath: index.js
 * @Author: 杜芬
 * @Date: 2021-11-25 16:45:48
 * @LastEditors: Please set LastEditors
 * @LastEditTime: 2023-12-04 09:37:26
 * Copyright: 2023 xxxTech CO.,LTD. All Rights Reserved.
 * @Descripttion: 页面
 */
/*
 * @FilePath: index.js
 * @Author: 杜芬
 * @Date: 2021-11-25 16:45:48
 * @LastEditors: Please set LastEditors
 * @LastEditTime: 2023-07-31 16:12:48
 * Copyright: 2023 xxxTech CO.,LTD. All Rights Reserved.
 * @Descripttion: 页面
 */

import Vue from 'vue'
import Router from 'vue-router'

Vue.use(Router)

/* Layout */
import Layout from '@/layout'
export const constantRoutes = [
  {
    path: '/login',
    component: () => import('@/views/login/index'),
    hidden: true
  },

  {
    path: '/404',
    component: () => import('@/views/404'),
    hidden: true
  },

  {
    path: '/',
    component: Layout,
    redirect: '/dashboard',
    children: [
      {
        path: 'dashboard',
        name: 'Dashboard',
        component: () => import('@/views/dashboard/index'),
        meta: { title: 'Dashboard', icon: 'dashboard' }
      }
    ]
  },
  {
    path: '/analysis-exception',
    component: Layout,
    redirect: '/analysis-exception/analysis-exception',
    name: 'Example',
    meta: { title: '异常分析', icon: 'el-icon-s-help' },
    children: [
      {
        path: 'analysis-exception',
        name: '异常分析',
        component: () => import('@/views/analysisException/index'),
        meta: { title: '异常分析', icon: 'dashboard' }
      },
      {
        path: 'report',
        name: '报告',
        component: () => import('@/views/report/index'),
        meta: { title: '报告', icon: 'el-icon-s-custom' }
      },
      {
        path: 'evaluationTask',
        name: '测评任务',
        component: () => import('@/views/evaluationTask/evaluationTask'),
        meta: { title: '测评任务', icon: 'el-icon-s-custom' }
      },
      {
        path: 'myComponents',
        name: '报告',
        component: () => import('@/views/myComponents/index'),
        meta: { title: '组件', icon: 'el-icon-s-help' }
      }
    ]
  },
  {
    path: '/tag-group',
    component: Layout,
    redirect: '/tagGroup',
    name: 'Example',
    meta: { title: '群体标签分析', icon: 'el-icon-s-help' },
    children: [
      {
        path: 'tag-group',
        name: '群体标签分析',
        component: () => import('@/views/tagGroup/index'),
        meta: { title: '群体标签分析', icon: 'dashboard' }
      },
      {
        path: 'conternt-box',
        name: '组件',
        component: () => import('@/views/conterntBox/index'),
        meta: { title: '组件', icon: 'dashboard' }
      }
    ]
  },
  {
    path: '/tag-page',
    component: Layout,
    redirect: '/tagPage',
    children: [
      {
        path: 'tag-group',
        name: '组件',
        component: () => import('@/views/tagPage/index'),
        meta: { title: '组件', icon: 'dashboard' }
      }
    ]
  },
  {
    path: '/tag-page-item',
    component: Layout,
    redirect: '/tagPage',
    children: [
      {
        path: 'tag-group-item',
        name: '进度条',
        component: () => import('@/views/tagPageItem/index'),
        meta: { title: '进度条', icon: 'dashboard' }
      }
    ]
  },
  {
    path: '/tag-echart',
    component: Layout,
    redirect: '/tagEchart',
    name: 'tagEchart',
    children: [
      {
        path: 'tag-echart',
        name: '图表echart',
        component: () => import('@/views/tagEchart/index'),
        meta: { title: '图表echart', icon: 'dashboard' }
      }
    ]
  },
  {
    path: '/map',
    component: Layout,
    redirect: '/map',
    name: 'map地图',

    children: [
      {
        path: 'map',
        name: 'map地图',
        component: () => import('@/views/map/index'),
        meta: { title: 'map', icon: 'table' }
      }
    ]
  },
  {
    path: '/tag-table',
    component: Layout,
    redirect: '/tagTable',
    children: [
      {
        path: 'tag-table',
        name: '表格',
        component: () => import('@/views/tagTable/index'),
        meta: { title: '表格', icon: 'dashboard' }
      }
    ]
  },
  {
    path: '/energy-page',
    component: Layout,
    redirect: '/energyPage',
    children: [
      {
        path: 'energy-page',
        name: '能效诊断报告审核',
        component: () => import('@/views/energyPage/index'),
        meta: { title: '能效诊断报告审核', icon: 'dashboard' }
      }
    ]
  },

  {
    path: '/example',
    component: Layout,
    redirect: '/example/table',
    name: 'Example',
    meta: { title: '工具箱', icon: 'el-icon-s-help' },
    children: [
      {
        path: 'table',
        name: 'Table',
        component: () => import('@/views/table/index'),
        meta: { title: 'Table', icon: 'table' }
      },
      {
        path: 'tree',
        name: 'Tree',
        component: () => import('@/views/tree/index'),
        meta: { title: '树形结构', icon: 'tree' }
      },
      {
        path: 'tableTo',
        name: 'tableTo',
        component: () => import('@/views/tableTo/tableTo'),
        meta: { title: '表格', icon: 'table' }
      },
      {
        path: 'tableTwo',
        name: 'tableTwo',
        component: () => import('@/views/tableTwo/tableTwo'),
        meta: { title: '表格2', icon: 'table' }
      },
      {
        path: 'time',
        name: 'time',
        component: () => import('@/views/time/index.vue'),
        meta: { title: '时间', icon: 'el-icon-date' }
      },
      {
        path: 'operatePage',
        name: 'operatePage',
        component: () => import('@/views/CarbonAccounting/index.vue'),
        meta: { title: '运营看板', icon: 'el-icon-s-platform' }
      },
      {
        path: 'panelPage',
        name: 'panelPage',
        // src\views\CarbonAccounting\page\index.vue
        component: () => import('@/views/CarbonAccounting/page/index.vue'),
        meta: { title: '通用面板', icon: 'el-icon-s-platform' }
      },
      {
        path: 'form',
        name: 'form',
        component: () => import('@/views/formChildren/index.vue'),
        meta: { title: '表单', icon: 'el-icon-date' }
      },
      {
        path: 'form-item',
        name: 'form-item',
        component: () => import('@/views/formItem/index.vue'),
        meta: { title: '练习', icon: 'el-icon-tickets' }
      },
      {
        path: 'Exercises',
        name: 'Exercises',
        component: () => import('@/views/Exercises/index.vue'),
        meta: { title: '练习2', icon: 'el-icon-tickets' }
      },
      {
        path: 'ExercisesPage',
        name: 'ExercisesPage',
        component: () => import('@/views/ExercisesPage/index.vue'),
        meta: { title: '练习3', icon: 'el-icon-tickets' }
      },
      {
        path: 'formList',
        name: 'formList',
        component: () => import('@/views/formList/index.vue'),
        meta: { title: '购物车', icon: 'el-icon-tickets' }
      },
      {
        path: 'shopping',
        name: 'shopping',
        component: () => import('@/views/shopping/index.vue'),
        meta: { title: '购物车02', icon: 'el-icon-tickets' }
      },
      {
        path: 'shopping2',
        name: 'shopping2',
        component: () => import('@/views/shopping2/index.vue'),
        meta: { title: '购物车2', icon: 'el-icon-tickets' }
      },
      {
        path: 'shopping3',
        name: 'shopping3',
        component: () => import('@/views/shopping2/index.vue'),
        meta: { title: '购物车3', icon: 'el-icon-tickets' }
      }
    ]
  },

  {
    path: '/form',
    component: Layout,
    children: [
      {
        path: 'index',
        name: 'Form',
        component: () => import('@/views/form/index'),
        meta: { title: 'Form', icon: 'form' }
      }
    ]
  },

  {
    path: '/nested',
    component: Layout,
    redirect: '/nested/menu1',
    name: 'Nested',
    meta: {
      title: 'Nested',
      icon: 'nested'
    },
    children: [
      {
        path: 'menu1',
        component: () => import('@/views/nested/menu1/index'), // Parent router-view
        name: 'Menu1',
        meta: { title: 'Menu1' },
        children: [
          {
            path: 'menu1-1',
            component: () => import('@/views/nested/menu1/menu1-1'),
            name: 'Menu1-1',
            meta: { title: 'Menu1-1' }
          },
          {
            path: 'menu1-2',
            component: () => import('@/views/nested/menu1/menu1-2'),
            name: 'Menu1-2',
            meta: { title: 'Menu1-2' },
            children: [
              {
                path: 'menu1-2-1',
                component: () => import('@/views/nested/menu1/menu1-2/menu1-2-1'),
                name: 'Menu1-2-1',
                meta: { title: 'Menu1-2-1' }
              },
              {
                path: 'menu1-2-2',
                component: () => import('@/views/nested/menu1/menu1-2/menu1-2-2'),
                name: 'Menu1-2-2',
                meta: { title: 'Menu1-2-2' }
              }
            ]
          },
          {
            path: 'menu1-3',
            component: () => import('@/views/nested/menu1/menu1-3'),
            name: 'Menu1-3',
            meta: { title: 'Menu1-3' }
          }
        ]
      },
      {
        path: 'menu2',
        component: () => import('@/views/nested/menu2/index'),
        name: 'Menu2',
        meta: { title: 'menu2' }
      }
    ]
  },

  {
    path: 'external-link',
    component: Layout,
    children: [
      {
        path: 'https://panjiachen.github.io/vue-element-admin-site/#/',
        meta: { title: 'External Link', icon: 'link' }
      }
    ]
  },

  // 404 page must be placed at the end !!!
  { path: '*', redirect: '/404', hidden: true }
]

const createRouter = () =>
  new Router({
    // mode: 'history', // require service support
    scrollBehavior: () => ({ y: 0 }),
    routes: constantRoutes
  })

const router = createRouter()

// Detail see: https://github.com/vuejs/vue-router/issues/1234#issuecomment-357941465
export function resetRouter() {
  const newRouter = createRouter()
  router.matcher = newRouter.matcher // reset router
}

export default router
